package cn.xiaopengstack.domain.activity.event;

import cn.xiaopengstack.types.config.RocketMqTopicProperties;
import cn.xiaopengstack.types.event.BaseEvent;
import cn.xiaopengstack.types.utils.SpringContextUtil;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;

/**
 * @author jiangyangang
 */
@Slf4j
public class ActivitySkuStockZeroMessageEvent<T> extends BaseEvent<ActivitySkuStockZeroMessageEvent.ActivitySkuStockZeroMessage> {


    public ActivitySkuStockZeroMessageEvent(ActivitySkuStockZeroMessage data, String key) {
        super(data, key);
    }

    @Override
    public String topic() {
        return SpringContextUtil.getBean(RocketMqTopicProperties.class).getActivitySkuStockZero();
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class ActivitySkuStockZeroMessage{
        /**
         * 商品sku
         */
        private Long sku;
        /**
         * 活动ID
         */
        private Long activityId;
        /**
         * 扣减数量
         */
        private Integer decrNumber;

        /**
         * 结束时间
         */
        private Long endTime;
    }
}
